home *** CD-ROM | disk | FTP | other *** search
- unit thread1;
- interface
- uses
- Classes, StdCtrls, SysUtils;
-
- type
- TFirstThread = class(TThread)
- public
- CountLabel: TLabel;
- Synchrone,MaxCounter,Counter: LongInt;
- constructor Create(MaxCount,Sync: LongInt; Count: TLabel);
- procedure Execute; override;
- procedure UpdateCounter;
- end;
-
- implementation
-
- constructor TFirstThread.Create(MaxCount,Sync: LongInt; Count: TLabel);
- begin
- inherited Create(False);
- CountLabel := Count;
- MaxCounter := MaxCount;
- Synchrone := Sync;
- Counter := 0
- end;
-
- procedure TFirstThread.Execute;
- begin
- while (Counter < MaxCounter) and not Terminated do
- begin
- Inc(Counter);
- if (Counter mod Synchrone) = 0 then Synchronize(UpdateCounter)
- end
- end;
-
- procedure TFirstThread.UpdateCounter;
- begin
- CountLabel.Caption := Format('%d/%d',[Counter, MaxCounter])
- end;
-
- end.
-